package com.txc.config;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//拦截器
public class Myinterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Object rootSession = request.getSession().getAttribute("RootSession");
        if (rootSession == null){//没有登录
            request.setAttribute("msg","年轻人~你的想法很危险！");
            request.getRequestDispatcher("/rootindex.html").forward(request,response);
            return false;
        }
        return true;
     }
    }
